﻿using System;

namespace Creventive.Wpf.ShellFactory.Services
{
    /// <summary>
    ///   Defines what key type a given object instance should be paired with. The object must derive from this type
    /// </summary>
    [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true, Inherited = false)]
    public class ServiceAttribute : Attribute
    {
        private Type keyType;
        private Type instanceType;

        /// <summary>
        /// Initializes a new instance of the <see cref="ServiceAttribute"/> class.
        /// </summary>
        /// <param name="keyType">Type of the key.</param>
        /// <param name="instanceType">Type of the instance.</param>
        public ServiceAttribute(Type keyType, Type instanceType)
        {
            this.keyType = keyType;
            this.instanceType = instanceType;
            this.Mode = InstantiationMode.Normal;
        }

        /// <summary>
        /// Gets the type of the server instance for this service.
        /// </summary>
        /// <value>The type of the instance.</value>
        public Type InstanceType
        {
            get { return this.instanceType; }
        }

        /// <summary>
        /// Gets the type of the service to define.
        /// </summary>
        /// <value>The type of the key.</value>
        public Type KeyType
        {
            get { return this.keyType; }
        }

        /// <summary>
        /// Gets or sets how this service should be instantiated.
        /// </summary>
        /// <value>The mode.</value>
        public InstantiationMode Mode { get; set; }
    }
}